import {Button, Card, Checkbox, Space, Tag} from "antd";
import {journalsListApi} from "../../Api/literatureTracking.ts";
import {useEffect, useState} from "react";

const JournalsBox = () => {
    const [journalsList,setJournalsList] = useState([])
    async function getJournalsList() {
        const params = {
            current:1,
            orderBy:2,
            page_size:20,
            title:''
        }
        const {code,data} = await journalsListApi(params)
        if(code===0){
            setJournalsList(data.list)
        }
    }

    useEffect(() => {
        getJournalsList()
    }, []);
    return (
        <div style={{height:'calc(100vh - 260px)',overflow:'auto'}}>
            {
                journalsList.map((item:any,index:number)=>(
                    <Card style={{marginBottom:10}}>
                        <Space>
                            <Tag bordered={false} color="processing">
                                {item.journalName}
                            </Tag>
                            <Button size='small' type="primary">取消关注</Button>
                        </Space>
                        <div>
                            <Checkbox style={{margin:'10px 0'}}>{item.title}</Checkbox>
                            <div>
                                <Tag bordered={false} color="processing">
                                    摘要
                                </Tag>
                                {item.abstractContent}
                            </div>
                            <div style={{marginTop:10}}>
                                <Space>
                                    <div>发表时间：{item.updateTime}</div>
                                    <Button size='small' type="primary">查看详情</Button>
                                    <Button size='small' type="primary">添加到项目</Button>
                                </Space>
                            </div>
                        </div>
                    </Card>
                ))
            }
        </div>
    )
}

export default JournalsBox